﻿using SaaS.Model.Enums;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Text;
using XCore.Redis;

namespace SaaS.Model.Dto.Systems
{
    public struct SystemAdminModel
    {
        /// <summary>
        /// 管理员Id
        /// </summary>
        public int AdminId;
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName;
        /// <summary>
        /// 注册时间
        /// </summary>
        public DateTime CreationTime;
        /// <summary>
        /// 密码
        /// </summary>
        public string Password;
        /// <summary>
        /// 名称
        /// </summary>
        public string Name;
        /// <summary>
        /// 角色Id
        /// </summary>
        public int RoleId;
        /// <summary>
        /// 是否默认超级管理员
        /// </summary>
        public bool IsDefault;
        /// <summary>
        /// 状态
        /// </summary>
        public UserStatus Status;
        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar;

        public static implicit operator SystemAdminModel(HashEntry[] hash)
        {
            return hash.GetReidsHashValue<SystemAdminModel>();
        }
        public static implicit operator HashEntry[](SystemAdminModel model)
        {
            return model.GetRedisHashEntry();
        }
        public static implicit operator bool(SystemAdminModel model)
        {
            return model.AdminId != 0;
        }
    }
}
